package com.iversonx.example_1.controller.v2.impl;

import com.iversonx.example_1.controller.AwardReq;
import com.iversonx.example_1.controller.v2.PrizeService;
import com.iversonx.example_1.service.card.CardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CardPrizeService implements PrizeService {
    private final Logger logger = LoggerFactory.getLogger(CardPrizeService.class);

    @Autowired
    private CardService cardService;

    @Override
    public boolean support(Integer awardType) {
        return awardType == 3;
    }

    @Override
    public void sendCommodity(AwardReq req) throws Exception {
        logger.info("请求参数[爱奇艺兑换卡] => {}", req);
        String mobile = queryUserPhoneNumber(req.getUId());
        cardService.grantToken(mobile, req.getBizId());
        logger.info("测试结果[爱奇艺兑换卡]：success");
    }

    private String queryUserPhoneNumber(String uId) {
        return "15200101232";
    }
}
